/**
 * Created by s_ on 15/11/29.
 */

var USER_MENU_KEY = 'userMenuOpen';
Session.setDefault(USER_MENU_KEY, false);

Template.navHeader.helpers({
    menuOpen: function() {
        return Session.get(MENU_KEY) && 'menu-open';
    },
    emailLocalPart: function() {
        var email = Meteor.user().emails[0].address;
        return email.substring(0, email.indexOf('@'));
    },

    userMenuOpen: function() {
        return Session.get(USER_MENU_KEY);
    },
});
Template.navHeader.events({
    'click .js-user-menu': function(event) {
        Session.set(USER_MENU_KEY, ! Session.get(USER_MENU_KEY));
        // stop the menu from closing
        event.stopImmediatePropagation();
    },
})
